local lianhua = fk.CreateSkill {
  name = "ym_water__lianhua",
  dynamic_desc = function (self, player, lang)
    return "ym_water__lianhua"..player:getMark(self.name)
  end,
}

Fk:loadTranslationTable{
  ["ym_water__lianhua"] = "莲华",
  [":ym_water__lianhua"] = "当你成为【杀】的目标时，你摸一张牌。<br>二阶：当你成为【杀】的目标时，你摸一张牌，然后你判定，若为♠，取消之。<br>"..
  "三阶：当你成为【杀】的目标时，你摸一张牌，然后使用者需弃置一张牌，否则取消之。",

  [":ym_water__lianhua0"] = "当你成为【杀】的目标时，你摸一张牌。",
  [":ym_water__lianhua1"] = "当你成为【杀】的目标时，你摸一张牌，然后你判定，若为♠，取消之。",
  [":ym_water__lianhua2"] = "当你成为【杀】的目标时，你摸一张牌，然后使用者需弃置一张牌，否则取消之。",

  ["#ym_water__lianhua-discard"] = "莲华：你需弃置一张牌，否则 %src 取消此【杀】",

  ["$ym_water__lianhua1"] = "刀兵水火，速离身形。",
  ["$ym_water__lianhua2"] = "体有金光，覆映全身。",
}

lianhua:addEffect(fk.TargetConfirming, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(lianhua.name) and data.card.trueName == "slash"
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, lianhua.name)
    if player.dead or player:getMark(lianhua.name) == 0 then return end
    if player:getMark(lianhua.name) == 1 then
      local judge = {
        who = player,
        reason = lianhua.name,
        pattern = ".|.|spade",
      }
      room:judge(judge)
      if judge:matchPattern() then
        data:cancelTarget(player)
      end
    elseif player:getMark(lianhua.name) == 2 then
      if data.from.dead or data.from:isNude() or
        #room:askToDiscard(data.from, {
          min_num = 1,
          max_num = 1,
          include_equip = true,
          skill_name = lianhua.name,
          cancelable = true,
          prompt = "#ym_water__lianhua-discard:"..player.id,
        }) == 0 then
          data:cancelTarget(player)
      end
    end
  end,
})

return lianhua
